package com.elcom.roaming.common.server;

import org.slf4j.Logger;

import com.elcom.ipc_as_smpp.ipcserver.IpcServerBootstrap;
import com.elcom.roaming.common.config.ConfigModule;
import com.elcom.roaming.module.collection.match.UIMatchingObjects;
import com.elcom.roaming.module.synthesis.isup.ISUPMatchingObjects;
import com.elcom.roaming.module.synthesis.pr.PRMatchingObjects;

public class SMPPServer {
	private Logger logger;
	private IpcServerBootstrap lbServer;
	private UIMatchingObjects uiMatching;
	private ISUPMatchingObjects isupMatching;
	private PRMatchingObjects prMatching;
	private String name;
	private String cfgFile;
	
	public SMPPServer(Logger logger, String name, String cfgFile, UIMatchingObjects matching) {
		this.logger = logger;
		this.name = name;
		this.cfgFile = cfgFile;
		this.uiMatching = matching;
	}
	
	public SMPPServer(Logger logger, String name, String cfgFile, ISUPMatchingObjects isupMatching, PRMatchingObjects prMatching) {
		this.logger = logger;
		this.name = name;
		this.cfgFile = cfgFile;
		this.isupMatching = isupMatching;
		this.prMatching = prMatching;
	}
	
	public void start() throws Throwable{
		if (ConfigModule.isSynthesisModule())
			lbServer = new IpcServerBootstrap(logger, name, cfgFile, new SMPPMessageListener(logger, isupMatching, prMatching), null);
		else 
			lbServer = new IpcServerBootstrap(logger, name, cfgFile, new SMPPMessageListener(logger, uiMatching), null);
		lbServer.execute();
	}
	
}
